<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/news.css"/>
    <style>
        li {
            list-style: inherit !important;
        }
    </style>
</head>

<body class="childrenBody">
<form class="layui-form" action="">
                                                    <div class="layui-form-item">
                    <label class="layui-form-label">userid</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入userid" class="layui-input"
                               id="userid">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">ordertype</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入ordertype" class="layui-input"
                               id="ordertype">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入创建时间" class="layui-input"
                               id="createtime">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">支付类型 </label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入支付类型 " class="layui-input"
                               id="paytype">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">订单号</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入订单号" class="layui-input"
                               id="orderno">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">总金额</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入总金额" class="layui-input"
                               id="totalamount">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">实际支付</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入实际支付" class="layui-input"
                               id="realpay">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">国id</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入国id" class="layui-input"
                               id="countryid">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">省id</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入省id" class="layui-input"
                               id="provinceid">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">cityid</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入cityid" class="layui-input"
                               id="cityid">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">regionid</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入regionid" class="layui-input"
                               id="regionid">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">地址</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入地址" class="layui-input"
                               id="address">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">收货人姓名</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入收货人姓名" class="layui-input"
                               id="receivername">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">收货人电话</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入收货人电话" class="layui-input"
                               id="receiverphone">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">纬度</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入纬度" class="layui-input"
                               id="lat">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">经度</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入经度" class="layui-input"
                               id="lon">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">订单状态</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入订单状态" class="layui-input"
                               id="status">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入备注" class="layui-input"
                               id="memo">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">运费</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入运费" class="layui-input"
                               id="freight">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">优惠金额</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入优惠金额" class="layui-input"
                               id="discount">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">配送员id</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入配送员id" class="layui-input"
                               id="courierid">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">优惠券id</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入优惠券id" class="layui-input"
                               id="discountid">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">支付时间</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入支付时间" class="layui-input"
                               id="paytime">
                    </div>
                </div>
                                                            <div class="layui-form-item">
                    <label class="layui-form-label">完成时间</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="required" placeholder="请输入完成时间" class="layui-input"
                               id="endtime">
                    </div>
                </div>
                        
    <div class="layui-form-item">
        <div class="layui-input-block">
            <a style="display:none;" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="edit"
               id="edit">立即修改</a>
            <a style="display:none;" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="add" id="add">立即提交</a>
            <a class="layui-btn layui-btn-primary close">关闭</a>
        </div>
    </div>
</form>
<script type="text/javascript" src="../../js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../../layui/layui.js"></script>
<script type="text/javascript" src="../../js/wangEditor.js"></script>
<script type="text/javascript" src="../../js/basic.js"></script>
<script>

    function edit() {
        var id = GetQueryString("id");
        var topM = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
        $.ajax({
            type: "post",
            url: "/orderhead/update",
            data: {
                                                                            userid : $("#userid").val(),
                                                                                    ordertype : $("#ordertype").val(),
                                                                                    createtime : $("#createtime").val(),
                                                                                    paytype : $("#paytype").val(),
                                                                                    orderno : $("#orderno").val(),
                                                                                    totalamount : $("#totalamount").val(),
                                                                                    realpay : $("#realpay").val(),
                                                                                    countryid : $("#countryid").val(),
                                                                                    provinceid : $("#provinceid").val(),
                                                                                    cityid : $("#cityid").val(),
                                                                                    regionid : $("#regionid").val(),
                                                                                    address : $("#address").val(),
                                                                                    receivername : $("#receivername").val(),
                                                                                    receiverphone : $("#receiverphone").val(),
                                                                                    lat : $("#lat").val(),
                                                                                    lon : $("#lon").val(),
                                                                                    status : $("#status").val(),
                                                                                    memo : $("#memo").val(),
                                                                                    freight : $("#freight").val(),
                                                                                    discount : $("#discount").val(),
                                                                                    courierid : $("#courierid").val(),
                                                                                    discountid : $("#discountid").val(),
                                                                                    paytime : $("#paytime").val(),
                                                                                    endtime : $("#endtime").val(),
                                                    orderheadId:id
    },
        dataType: "json",
                success
    :

        function (data) {
            backData(data, topM);
        }
    })
        ;
    }

    function add() {
        var topM = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
        $.ajax({
            type: "post",
            url: "/orderhead/save",
            data: {
                                                                            userid : $("#userid").val(),
                                                                                    ordertype : $("#ordertype").val(),
                                                                                    createtime : $("#createtime").val(),
                                                                                    paytype : $("#paytype").val(),
                                                                                    orderno : $("#orderno").val(),
                                                                                    totalamount : $("#totalamount").val(),
                                                                                    realpay : $("#realpay").val(),
                                                                                    countryid : $("#countryid").val(),
                                                                                    provinceid : $("#provinceid").val(),
                                                                                    cityid : $("#cityid").val(),
                                                                                    regionid : $("#regionid").val(),
                                                                                    address : $("#address").val(),
                                                                                    receivername : $("#receivername").val(),
                                                                                    receiverphone : $("#receiverphone").val(),
                                                                                    lat : $("#lat").val(),
                                                                                    lon : $("#lon").val(),
                                                                                    status : $("#status").val(),
                                                                                    memo : $("#memo").val(),
                                                                                    freight : $("#freight").val(),
                                                                                    discount : $("#discount").val(),
                                                                                    courierid : $("#courierid").val(),
                                                                                    discountid : $("#discountid").val(),
                                                                                    paytime : $("#paytime").val(),
                                                                                    endtime : $("#endtime").val(),
                                                extra:
        1
    },
        dataType: "json",
                success
    :

        function (data) {
            backData(data, topM);
        }
    })

    };

    function backData(data, topM) {
        if (data.status == 0) {

            setTimeout(function () {
                layer.close(topM);
                top.layer.msg("修改成功！");
                //刷新父页面
                parent.getList({});
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            }, 500);
        } else {
            layer.close(topM);
            layer.msg(data.msg, {icon: 1});
        }
    }

    function begin() {
        var op = GetQueryString("op");
        if (op == "add") {
            $("#add").show();
            return;
        }
        if (op == "edit") {
            $("#edit").show();
        }
        var id = GetQueryString("id");
        $.ajax({
            type: "post",
            url: "/orderhead/info",
            data: {
                    orderheadId: id
            },
            dataType: "json",
            success: function (data) {
                if (data.status == 0) {
                    
                        $("#id").val(data.result.id);

                    
                        $("#userid").val(data.result.userid);

                    
                        $("#ordertype").val(data.result.ordertype);

                    
                        $("#createtime").val(data.result.createtime);

                    
                        $("#paytype").val(data.result.paytype);

                    
                        $("#orderno").val(data.result.orderno);

                    
                        $("#totalamount").val(data.result.totalamount);

                    
                        $("#realpay").val(data.result.realpay);

                    
                        $("#countryid").val(data.result.countryid);

                    
                        $("#provinceid").val(data.result.provinceid);

                    
                        $("#cityid").val(data.result.cityid);

                    
                        $("#regionid").val(data.result.regionid);

                    
                        $("#address").val(data.result.address);

                    
                        $("#receivername").val(data.result.receivername);

                    
                        $("#receiverphone").val(data.result.receiverphone);

                    
                        $("#lat").val(data.result.lat);

                    
                        $("#lon").val(data.result.lon);

                    
                        $("#status").val(data.result.status);

                    
                        $("#memo").val(data.result.memo);

                    
                        $("#freight").val(data.result.freight);

                    
                        $("#discount").val(data.result.discount);

                    
                        $("#courierid").val(data.result.courierid);

                    
                        $("#discountid").val(data.result.discountid);

                    
                        $("#paytime").val(data.result.paytime);

                    
                        $("#endtime").val(data.result.endtime);

                                    } else {
                    layer.msg(data.msg, {icon: 1});
                }
            }
        });
    }

    //点击取消关闭当前弹窗
    $(".close").click(function () {
//当你在iframe页面关闭自身时
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    })

    layui.use(['form'], function () {
        var form = layui.form;
        //监听提交
        form.on('submit(add)', function (data) {
            add()
            return false;
        });

        //监听提交
        form.on('submit(edit)', function (data) {
            edit()
            return false;
        });
        begin();
    });

</script>
</body>
</html>